import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:tender_flutter/constant/resource_path.dart';
import 'package:tender_flutter/constant/theme_colors.dart';
import 'package:tender_flutter/utils/screen_adaper.dart';

class FormPictureItem extends StatelessWidget {
  const FormPictureItem({this.key, this.title, this.callback, this.imgFile})
      : super(key: key);

  final Key key;

  /// 标题
  final String title;

  /// 图片文件
  final File imgFile;

  /// 选择回调
  final GestureTapCallback callback;

  @override
  Widget build(BuildContext context) {
    return _getOptionsItem();
  }

  /// 选择类型的图片Item
  Widget _getOptionsItem() {
    return Container(
        margin: EdgeInsets.symmetric(
            vertical: ScreenAdapter.height(20),
            horizontal: ScreenAdapter.width(30)),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            Container(
                width: ScreenAdapter.width(150),
                child: Text(title,
                    style: TextStyle(
                        color: ThemeColors.colorType1,
                        fontSize: ScreenAdapter.sp(30)))),
            GestureDetector(
                onTap: callback,
                child: Container(
                    child: ClipRRect(
                      borderRadius: BorderRadius.circular(10),
                      child: imgFile != null
                          ? Image.file(imgFile, fit: BoxFit.cover)
                          : Image.asset(
                              RPath.imgPath + "img_add_placeholder.png",
                              fit: BoxFit.cover),
                    ),
                    width: ScreenAdapter.width(170),
                    height: ScreenAdapter.width(170)))
          ],
        ));
  }
}
